<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"
%><%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"
%><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"
%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
%>
<head>
    <title><fmt:message key="contentlet" /></title>
</head>
<body>
	<script language="JavaScript">
	<!--
		dojo.addOnLoad(function() {

			dojo.query(".relationAjaxDelete").forEach(function(element) {
				Spring.addDecoration(new Spring.AjaxEventDecoration({
					elementId: element.id,
					event: "onclick",
					popup: "true",
					params: { decorator: "none" }
				}));
			})
		});
	//-->
	</script>
    <h1><fmt:message key="contentlet" /></h1>
    <div class="buttons">
		<c:url var="createUrl" value="/domain/contentlet/createForm">
			<c:param name="contentlet.structureInode" value="${contentlet.structureInode}" />
		</c:url>
		<a href="${createUrl}"><span><fmt:message key="label.link.create" /></span></a>
    </div>

    <table>
        <tbody>
  
            <tr>
                <th><fmt:message key="contentlet_fileAsset" /></th>
                <td>
                    <img src="${adminHttpUrl}${contentlet.fileAsset.path}" width="40" height="40"/>                
				</td>
                <th><fmt:message key="contentlet_iconInode" /></th>
                <td>
                    <img src="${adminHttpUrl}${contentlet.iconFileAsset.path}" width="40" height="40"/>                
				</td>
            </tr>
            <tr>
                <th><fmt:message key="contentlet_title" /></th>
                <td>
                    <c:out value="${contentlet.title}"/>                
				</td>
                <th><fmt:message key="contentlet_friendlyName" /></th>
                <td>
                    <c:out value="${contentlet.friendlyName}"/>                
				</td>
            </tr>
		
			<tr>
                <th><fmt:message key="contentlet_live" /></th>
                <td>
                    <c:out value="${contentlet.live}"/>                </td>
                <th><fmt:message key="contentlet_locked" /></th>
                <td>
                    <c:out value="${contentlet.locked}"/>              
				</td>
            </tr>
            <tr>
                <th><fmt:message key="contentlet_showOnMenu" /></th>
                <td>
                    <c:out value="${contentlet.showOnMenu}"/>                
				</td>
                <th><fmt:message key="contentlet_sortOrder" /></th>
                <td>
                    <c:out value="${contentlet.sortOrder}"/>                
				</td>
            </tr>
            <tr>
                <th><fmt:message key="contentlet_modDate" /></th>
                <td>
                    <c:out value="${contentlet.modDate}"/>                </td>
                <th><fmt:message key="contentlet_modUser" /></th>
                <td>
                    <c:out value="${contentlet.modUser}"/>               
				</td>
            </tr>
            <tr>
                <th><fmt:message key="contentlet_structureInode" /></th>
                <td>
                    <c:out value="${contentlet.structureInode}"/>--<c:out value="${contentlet.structure.name}"/>
				</td>
                <th><fmt:message key="contentlet_folderInode" /></th>
                <td>
                    <c:out value="${contentlet.folderInode}"/>--<c:out value="${contentlet.folder.title}" />
				</td>
            </tr>
			<c:forEach items="${fields}" var="field" varStatus="status">
			<c:if test="${status.count % 2 == 1}">  
			<tr>  
			</c:if>    
				<th><c:out value="${field.field.fieldName}" /></th>
				<td>
					<c:choose>
						<c:when test="${field.field.fieldType == 'multicategory' || field.field.fieldType == 'category'}">
							<c:forEach items="${field.fieldValue}" var="value">
								<c:url var="categoryUrl" value="/domain/category/show.action">
									<c:param name="category.inode" value="${value.inode}" />
								</c:url>
								<a href="${categoryUrl}"><c:out value="${value.inode}"/>--<c:out value="${value.title}" /></a>
							</c:forEach>
						</c:when>
						<c:otherwise>
							<c:out value="${field.fieldValue}" />
						</c:otherwise>
					</c:choose>
				</td>
			<c:if test="${((status.count)) % 2 == 0}">  
			</tr>  
			</c:if>  
			</c:forEach>

            <tr>
                <th><fmt:message key="contentlet_content" /></th>
                <td colspan="3">
                    <c:out value="${contentlet.content}" />
				</td>
            </tr>
        </tbody>
        <tfoot>
            <tr>
                <td colspan="4">
                    <div class="buttons">
                        <c:url var="updateContetUrl" value="/domain/contentlet/updateContentForm.action">
                            <c:param name="contentlet.inode" value="${contentlet.inode}"/>
                        </c:url>
                        <a href="${updateContetUrl}"><span><fmt:message key="label.link.update"/>内容</span></a>
                        <c:url var="updateUrl" value="/domain/contentlet/updateForm.action">
                            <c:param name="contentlet.inode" value="${contentlet.inode}"/>
                        </c:url>
                        <a href="${updateUrl}"><span><fmt:message key="label.link.update"/></span></a>
                        <c:url var="confirmDeleteUrl" value="/domain/contentlet/confirmDelete.action">
                            <c:param name="contentlet.inode" value="${contentlet.inode}"/>
                        </c:url>
                        <a id="confirmDeleteUrl" href="${confirmDeleteUrl}"><span><fmt:message key="label.link.delete"/></span></a>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.AjaxEventDecoration({
                                elementId: "confirmDeleteUrl",
                                event: "onclick",
                                popup: "true",
                                params: { decorator: "none" }
                            }));
                        </script>
                    </div>
                </td>
            </tr>
        </tfoot>
    </table>
	<h2>相关内容</h2>
	<c:if test="${not empty contentletRelationships and not empty contentletRelationships.relationshipsRecords}">
		<c:forEach items="${contentletRelationships.relationshipsRecords}" var="relationshipsRecord">
			<div><b>${relationshipsRecord.relationship.childStructure.name}</b>
			${relationshipsRecord.hasParent ? relationshipsRecord.relationship.parentRelationName : relationshipsRecord.relationship.childRelationName}</div>
			<div class="buttons">
				<c:url var="createUrl1" value="/domain/fileAsset/createForm">
					<c:param name="contentletInode" value="${contentlet.inode}" />
					<c:param name="relationshipInode" value="${relationshipsRecord.relationship.inode}" />
				</c:url>
				<a href="${createUrl1}"><span><fmt:message key="label.link.create" /></span></a>
			</div>
			<div>
				<table class="listEntities">
					<thead>
						<tr>
							<th scope="col"><fmt:message key="contentlet_title"/></th>
							<th scope="col"><fmt:message key="contentlet_modDate"/></th>
							<th scope="col"><fmt:message key="contentlet_modUser"/></th>
							<th scope="col">&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${relationshipsRecord.records}" var="record">
						<tr>
							<td>
								<c:out value="${record.title}"/>
							</td>
							<td>
								<c:out value="${record.modDate}"/>
							</td>
							<td>
								<c:out value="${record.modUser}"/>
							</td>
						</tr>
					</c:forEach>
					</tbody>
				</table>
			</div>
		</c:forEach>
	</c:if>

	<c:if test="${not empty contentletFileAssetRelationships and not empty contentletFileAssetRelationships.relationshipsRecords}">
		<c:forEach items="${contentletFileAssetRelationships.relationshipsRecords}" var="relationshipsRecord">
			<div><b>${relationshipsRecord.relationship.childStructure.name}</b>
			${relationshipsRecord.hasParent ? relationshipsRecord.relationship.parentRelationName : relationshipsRecord.relationship.childRelationName}</div>
			<div class="buttons">
				<c:url var="createUrl1" value="/domain/fileAsset/createForm">
					<c:param name="contentletInode" value="${contentlet.inode}" />
					<c:param name="relationshipInode" value="${relationshipsRecord.relationship.inode}" />
				</c:url>
				<a href="${createUrl1}"><span><fmt:message key="label.link.create" /></span></a>
			</div>

			<div>
				<table class="listEntities">
					<thead>
						<tr>
							<th scope="col">&nbsp;</th>
							<th scope="col"><fmt:message key="contentlet_title"/></th>
							<th scope="col"><fmt:message key="contentlet_modDate"/></th>
							<th scope="col"><fmt:message key="contentlet_modUser"/></th>
							<th scope="col"><fmt:message key="fileAsset_path"/></th>
							<th scope="col">&nbsp;</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${relationshipsRecord.records}" var="record" varStatus="status">
						<tr>
							<td>
								<img src="${adminHttpUrl}${record.path}" width="60" heigth="60" />
							</td>
							<td>
								<c:out value="${record.title}"/>
							</td>
							<td>
								<c:out value="${record.modDate}"/>
							</td>
							<td>
								<c:out value="${record.modUser}"/>
							</td>
							<td>
								<c:out value="${record.path}"/>
							</td>
							<td>
								<c:if test="${(record.inode != contentlet.fileAsset.inode and relationshipsRecord.relationship.childStructureInode == 1) or (record.inode != contentlet.iconFileAsset.inode and relationshipsRecord.relationship.childStructureInode == 2)}">
								<c:url var="defaultUrl" value="/domain/contentlet/defaultFile">
									<c:param name="contentlet.inode" value="${contentlet.inode}" />
									<c:param name="fileAssetInode" value="${record.inode}" />
									<c:param name="type" value="${relationshipsRecord.relationship.childStructureInode}" />
								</c:url>
								<a href="${defaultUrl}">设为默认</a>
								<c:url var="deleteUrl" value="/domain/relationship/confirmDelete">
									<c:param name="parent" value="${contentlet.inode}" />
									<c:param name="child" value="${record.inode}" />
									<c:param name="relationship.inode" value="${relationshipsRecord.relationship.inode}" />
								</c:url>
								<a class="actionDelete relationAjaxDelete" id="confirmDeleteUrl${status.index}" href="${deleteUrl}"><fmt:message key="label.link.delete"/></a>

								</c:if>
							</td>
						</tr>
					</c:forEach>
					</tbody>
				</table>
			</div>
		</c:forEach>
	</c:if>

    <h2><fmt:message key="contentContainer"/></h2>
    <div class="buttons">
       <c:url var="createUrl" value="/domain/contentContainer/createForm.action">
			<c:param name="contentContainer.contentletInode" value="${contentlet.inode}" />
	   </c:url>
       <a href="${createUrl}"><span><fmt:message key="label.link.create" /></span></a>
    </div>

    <table class="listEntities">
        <thead>
            <tr>
                <th scope="col">&nbsp;</th>
                <th scope="col"><fmt:message key="contentContainer_inode"/></th>
                <th scope="col"><fmt:message key="contentContainer_folderInode"/></th>
                <th scope="col"><fmt:message key="contentContainer_showOnMenu"/></th>
                <th scope="col"><fmt:message key="contentContainer_sortOrder"/></th>
                <th scope="col"><fmt:message key="contentContainer_beginTime"/></th>
                <th scope="col"><fmt:message key="contentContainer_endTime"/></th>
                <th scope="col"><fmt:message key="contentContainer_modDate"/></th>
                <th scope="col"><fmt:message key="contentContainer_modUser"/></th>
                <th scope="col">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
        <c:forEach items="${contentContainers}" var="contentContainer" varStatus="status">
            <tr>
				<td>
					<img src="${adminHttpUrl}${contentContainer.fileAsset.path}" width="60" height="60" />
				</td>
                <td>
                    <c:url var="showUrl2" value="/domain/container/show.action">
                        <c:param name="container.inode"><c:out value="${contentContainer.containerInode}"/></c:param>
                    </c:url>
                    <a href="${showUrl2}"><c:out value="${contentContainer.containerInode}"/>--<c:out value="${contentContainer.container.title}"/></a>
                </td>
                <td>
                    <c:url var="showUrl" value="/domain/folder/show.action">
                        <c:param name="folder.inode"><c:out value="${contentContainer.folderInode}"/></c:param>
                    </c:url>
                    <a href="${showUrl}"><c:out value="${contentContainer.folderInode}"/>--<c:out value="${contentContainer.folder.title}"/></a>
                </td>
                <td>
                    <c:out value="${contentContainer.showOnMenu}"/>
                </td>
                <td>
                    <c:out value="${contentContainer.sortOrder}"/>
                </td>
                <td>
                    <c:out value="${contentContainer.beginTime}"/>
                </td>
                <td>
                    <c:out value="${contentContainer.endTime}"/>
                </td>
                <td>
                    <c:out value="${contentContainer.modDate}"/>
                </td>
                <td>
                    <c:out value="${contentContainer.modUser}"/>
                </td>
                <td>
                    <c:url var="showUrl" value="/domain/contentContainer/updateFileForm.action">
                        <c:param name="contentContainer.inode" value="${contentContainer.inode}"/>
                    </c:url>
                    <c:url var="updateUrl" value="/domain/contentContainer/updateForm.action">
                        <c:param name="contentContainer.inode" value="${contentContainer.inode}"/>
                    </c:url>
                    <c:url var="confirmDeleteUrl" value="/domain/contentContainer/confirmDelete.action">
                        <c:param name="contentContainer.inode" value="${contentContainer.inode}"/>
                    </c:url>
                    <a class="actionshow" href="${showUrl}"><fmt:message key="label.link.update"/></a>
                    <a class="actionUpdate" href="${updateUrl}"><fmt:message key="label.link.update"/></a>
                    <a class="actionDelete relationAjaxDelete" id="confirmContainerDelete${status.index}" href="${confirmDeleteUrl}"><fmt:message key="label.link.delete"/></a>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</body>
